{% extends "base_site.html" %}

{% block content %}

<h1>{{ server.name }}</h1>
<h2>{{ server.ip }}</h2>
<div>{{ server.remark }}</div>
<h2>Commands</h2>
{% for cmd in cmds %}
	<li>{{ cmd.title }}: {{ cmd.cmd.text }} <input type="button" value="run" onclick="exec(this, {{ cmd.cmd.id }})" /></li>
{% endfor %}

<div id="cmd_result" class="display:none">
	<pre id="result">
	</pre>
</div>

<script type="text/javascript" src="/media/js/jquery.min.js"></script>
<script>
	function exec(btn, cmd_id)
	{
		$(btn).val("running...").attr("disabled", "true");
		$.get("/servers/{{ server.id }}/exe/" + cmd_id, function(xml){
			$("#cmd_result").show();
			$("#result").html(xml);
			$(btn).val("run").attr("disabled", "");
		});
	}
</script>
{% endblock %}